package com.sun.future;

import cn.hutool.core.thread.ThreadUtil;
import lombok.SneakyThrows;

import java.util.concurrent.FutureTask;

/**
 * @Author: Suncl
 * @Date: 2023/4/10 10:50
 */
public class Future01 {
    @SneakyThrows
    public static void main(String[] args) {


        FutureTask f1 = new FutureTask(() -> {
            ThreadUtil.sleep(3000);
            return "c1执行结束";
        });
        FutureTask f2 = new FutureTask(() -> "c2执行结束");

        Thread t1 = new Thread(f1);

        Thread t2 = new Thread(f2);
        t1.start();
        t2.start();
        System.out.println("f2执行结果" + f2.get());
        System.out.println("f1执行结果" + f1.get());





    }
}
